import request from "@/utils/request";

// 获取商品列表
export function getProductList(params) {
  return request({
    url: "/product/list",
    method: "get",
    params,
  });
}

// 获取商品详情
export function getProductDetail(id) {
  return request({
    url: `/product/${id}`,
    method: "get",
  });
}

// 新增商品
export function addProduct(data) {
  return request({
    url: "/product",
    method: "post",
    data,
  });
}

// 更新商品
export function updateProduct(data) {
  return request({
    url: "/product",
    method: "put",
    data,
  });
}

// 删除商品
export function deleteProduct(id) {
  return request({
    url: `/product/${id}`,
    method: "delete",
  });
}

// 批量删除商品
export function batchDeleteProducts(ids) {
  return request({
    url: `/product`,
    method: "delete",
    data: ids,
  });
}

// 更新商品状态
export function updateProductStatus(id, status) {
  return request({
    url: `/product/${id}/${status}`,
    method: "put",
  });
}

// 获取商品库存
export function getProductStock(productId) {
  return request({
    url: `/product/stock/${productId}`,
    method: "get",
  });
}
